package world;

public class Message implements Comparable<Message> {

    private long id;
    private java.sql.Timestamp data;
    private String tokens;
    private Author autor;
    private Issue issue;

    public Message() {
    }

    public Author getAutor() {
        return autor;
    }

    public void setAutor(Author autor) {
        this.autor = autor;
    }

    public java.sql.Timestamp getData() {
        return data;
    }

    public void setData(java.sql.Timestamp data) {
        this.data = data;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTokens() {
        return tokens;
    }
    public String[] getTokensArray() {
        return tokens.split(" ");
    }

    public String getTokens(double d) {
        String[] tokens = this.tokens.split(" ");
        int q = (int) (d * tokens.length);

        StringBuilder newTokens = new StringBuilder();
        for (int i = 0; i < q; i++) {
            newTokens.append(tokens[i]).append(" ");
        }
        return newTokens.toString();
    }

    public void setTokens(String tokens) {
        this.tokens = tokens;
    }

    public Issue getIssue() {
        return issue;
    }

    public void setIssue(Issue issue) {
        this.issue = issue;
    }

    @Override
    public int compareTo(Message other) {
        if (this.id > other.getId()) {
            return 1;
        } else if (this.id > other.getId()) {
            return -1;
        }
        return 0;
    }
}
